package zheezes.swt.databinding;

import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;

abstract class BeansObservableFactory implements IObservableFactory {
	private final Class<?> clazz;

	public BeansObservableFactory(Class<?> clazz) {
		this.clazz = clazz;
	}

	public IObservable createObservable(Object target) {
		if (target instanceof IObservable) {
			return (IObservable) target;
		}
		if (CalssUtil.instanceOf(clazz, target)) {
			return createBeanObservable(target);
		}
		return null;
	}

	protected abstract IObservable createBeanObservable(Object target);
}